/*   1:    */ package com.rinsi.util;
/*   2:    */ 
/*   3:    */ import java.text.NumberFormat;
/*   4:    */ import java.text.ParseException;
/*   5:    */ import java.text.SimpleDateFormat;
/*   6:    */ import java.util.Date;
/*   7:    */ import org.apache.poi.hssf.usermodel.HSSFCell;
/*   8:    */ 
/*   9:    */ public class FormaterUtil
/*  10:    */ {
/*  11:    */   public static String stringValue(Object obj)
/*  12:    */   {
/*  13: 28 */     if (AssertUtil.isStringNotEmpty(obj)) {
/*  14: 28 */       return String.valueOf(obj);
/*  15:    */     }
/*  16: 30 */     return "";
/*  17:    */   }
/*  18:    */   
/*  19:    */   public static Boolean booleanValue(Object obj)
/*  20:    */   {
/*  21: 42 */     if (AssertUtil.isBoolean(obj)) {
/*  22: 42 */       return Boolean.valueOf(stringValue(obj));
/*  23:    */     }
/*  24: 44 */     return Boolean.valueOf(false);
/*  25:    */   }
/*  26:    */   
/*  27:    */   public static Integer integerValue(Object obj)
/*  28:    */   {
/*  29: 56 */     if (AssertUtil.isInteger(obj)) {
/*  30: 56 */       return Integer.valueOf(stringValue(obj));
/*  31:    */     }
/*  32: 58 */     return null;
/*  33:    */   }
/*  34:    */   
/*  35:    */   public static Float floatValue(Object obj)
/*  36:    */   {
/*  37: 70 */     if (AssertUtil.isFloat(obj)) {
/*  38: 70 */       return Float.valueOf(stringValue(obj));
/*  39:    */     }
/*  40: 72 */     return null;
/*  41:    */   }
/*  42:    */   
/*  43:    */   public static Date dateValue(Object obj, String formatstr)
/*  44:    */     throws ParseException
/*  45:    */   {
/*  46: 88 */     SimpleDateFormat dateFormat = new SimpleDateFormat(formatstr);
/*  47:    */     
/*  48: 90 */     return dateFormat.parse(String.valueOf(obj));
/*  49:    */   }
/*  50:    */   
/*  51:    */   public static Date dateValue(Object obj)
/*  52:    */     throws ParseException
/*  53:    */   {
/*  54:105 */     return dateValue(String.valueOf(obj), "yyyy-MM-dd");
/*  55:    */   }
/*  56:    */   
/*  57:    */   public static String formatDateValue(Object obj, String formatstr)
/*  58:    */   {
/*  59:119 */     if ((obj == null) || (formatstr == null)) {
/*  60:119 */       return null;
/*  61:    */     }
/*  62:121 */     SimpleDateFormat dateFormat = new SimpleDateFormat(formatstr);
/*  63:    */     
/*  64:123 */     return dateFormat.format(obj);
/*  65:    */   }
/*  66:    */   
/*  67:    */   public static String formatDateValue(Object obj)
/*  68:    */   {
/*  69:135 */     return formatDateValue(obj, "yyyy-MM-dd");
/*  70:    */   }
/*  71:    */   
/*  72:    */   public static String convertCell(HSSFCell cell)
/*  73:    */   {
/*  74:140 */     NumberFormat formater = NumberFormat.getInstance();
/*  75:    */     
/*  76:142 */     formater.setGroupingUsed(false);
/*  77:    */     
/*  78:144 */     String cellValue = "";
/*  79:146 */     if (cell == null) {
/*  80:148 */       return cellValue;
/*  81:    */     }
/*  82:152 */     switch (cell.getCellType())
/*  83:    */     {
/*  84:    */     case 0: 
/*  85:156 */       cellValue = formater.format(cell.getNumericCellValue());
/*  86:    */       
/*  87:158 */       break;
/*  88:    */     case 1: 
/*  89:162 */       cellValue = cell.getStringCellValue();
/*  90:    */       
/*  91:164 */       break;
/*  92:    */     case 2: 
/*  93:168 */       cellValue = cell.getStringCellValue();
/*  94:    */       
/*  95:170 */       break;
/*  96:    */     case 3: 
/*  97:174 */       cellValue = cell.getStringCellValue();
/*  98:    */       
/*  99:176 */       break;
/* 100:    */     case 4: 
/* 101:180 */       cellValue = 
/* 102:181 */         Boolean.valueOf(cell.getBooleanCellValue()).toString();
/* 103:    */       
/* 104:183 */       break;
/* 105:    */     case 5: 
/* 106:187 */       cellValue = String.valueOf(cell.getErrorCellValue());
/* 107:    */       
/* 108:189 */       break;
/* 109:    */     default: 
/* 110:193 */       cellValue = "";
/* 111:    */     }
/* 112:199 */     return cellValue.trim();
/* 113:    */   }
/* 114:    */ }


/* Location:           D:\Users\Desktop\shanxi\项目\sxazmis\WEB-INF\classes\
 * Qualified Name:     com.rinsi.util.FormaterUtil
 * JD-Core Version:    0.7.0.1
 */